/**
 * 
 * 起迪科技 Copyright (c) 2014-2018 QiDi,Inc.All Rights Reserved.
 */
package cn.qidisoft.edu.hzjt.utils;

import cn.qidisoft.core.common.pagination.BaseDialect;

/**
 * 
 * @author hxq
 * @version $Id: SqlServerDialect.java, v 0.1 2018年10月23日 下午5:45:48 hxq Exp $
 */
public class SqlServerDialect extends BaseDialect {

  /**
   * @see cn.qidisoft.core.common.pagination.Dialect#getLimitString(java.lang.String, int, int)
   */
  @Override
  public String getLimitString(String sql, int offset, int maxRow) {
    sql = trim(sql);
    StringBuffer pagingSelect = new StringBuffer(sql.length() + 40);
    pagingSelect.append("SELECT TOP ");
    pagingSelect.append(maxRow);
    pagingSelect.append(" * FROM (");
    pagingSelect.append(sql);
    pagingSelect.append(") A WHERE ROWNUMBER >").append(offset);
    return pagingSelect.toString();
  }

}
